package com.foreveross.fetl.core.domain.freight.repository.impl;

import java.util.List;

import org.springframework.stereotype.Repository;

import com.foreveross.fetl.common.jpa.EntityHibernateRepository;
import com.foreveross.fetl.core.domain.freight.FreightMonitor;
import com.foreveross.fetl.core.domain.freight.repository.IFreightMonitorRepository;

@Repository("freightMonitorRepository")
public class FreightMonitorRepositoryImpl extends EntityHibernateRepository
	implements IFreightMonitorRepository{
	

	@Override
	public List<FreightMonitor>  findByCondition(Object[] objs,String flag) {
		if(flag.equals("date")){
			return super.queryResult(
					"select f from FreightMonitor f where f.type=? and f.grabChannelKey=? and fromCity=? and toCity=? and flightNo=? and flightDate=? and TO_DAYS(grabDate)=TO_DAYS(?) order by grabDate desc", objs);
		}else {
			return super.queryResult(
					"select f from FreightMonitor f where f.type=? and f.grabChannelKey=? and fromCity=? and toCity=? and flightNo=? and flightDate=? and grabDate=?", objs);
		}
		
	}

}
